<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
            <el-form-item label="城市ID" prop="cityId">
                <el-input v-model="queryParams.cityId" placeholder="请输入城市ID" clearable style="width: 240px" />
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            </el-form-item>
        </el-form>

        <el-table v-loading="loading" :data="hotelList">
            <el-table-column label="艺龙酒店ID" prop="HotelId" />
            <el-table-column label="酒店中文名称" prop="HotelName" />
            <el-table-column label="酒店状态" prop="HotelStatus">
                <template slot-scope="scope">
                    {{ getHotelStatusName(scope.row.HotelStatus) }}
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize" @pagination="getList" />
    </div>
</template>

<script>
import { getHotelList } from "@/api/hotel/hotel";
export default {

    data() {
        return {
            loading: false,
            showSearch: true,
            hotelList: [],
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                cityId: undefined
            },
            // 总条数
            total: 0
        }
    }, created() {
        //this.getList();
    }, methods: {
        getList() {
            this.loading = true;
            getHotelList(this.addDateRange(this.queryParams)).then(response => {
                this.hotelList = response.data.Result.Hotels;
                this.total = response.data.Result.Count;
                this.loading = false;
            }
            );
        },
        handleQuery() {
            if (this.queryParams.cityId) {
                this.queryParams.pageNum = 1;
                this.getList();
            } else {
                this.$message.error('请输入城市ID');
            }
        },
        getHotelStatusName(status) {

            switch (status) {
                case 0:
                    return '有效';
                case 1:
                    return '无效';
                case 2:
                    return '删除';
            }
        }
    }
}
</script>